package com.luke.nio.buffer;

import java.nio.IntBuffer;

public class BufferTest {

    public static void main(String[] args) {

        //mark 标志位
        //position 下一个读写位置
        //limit 限制下标
        //capacity 容量

        IntBuffer intBuffer = IntBuffer.allocate(5);
        for(int i = 0; i < intBuffer.capacity(); i++){
            intBuffer.put(i);
        }

        intBuffer.flip();//读写转换
        /*limit = position;
        position = 0;
        mark = -1;*/

        intBuffer.position(1);
        intBuffer.limit(3);

        while(intBuffer.hasRemaining()){
            System.out.println("元素："+intBuffer.get()); //输出 1 2
        }

    }

}
